<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<%@ include file="/common/common-jsp.jspf" %>
		<title>employee list</title>
		<link rel="stylesheet" type="text/css" href="${rootpath }/css/employee/list.css">
		<%-- <script type="text/javascript" src="${rootpath }/js/page.js"></script>  --%>
		<style>
		</style>
		<script>
			$(function() {
				$('.emp-delete').filter('a').click(function() {
					$('.emp-delete').filter('form').attr('action', $(this).attr('href')).submit();
					return false;
				});
			});
		</script>
	</head>
	<body>
		<div id="employee-list">
			<h3>employee list</h3>
			<hr>
			<%-- 这个 form 用于删除 --%>
			<form action="" method="post" class="emp-delete">
				<input type="hidden" name="_method" value="DELETE">
			</form>
			<div class="table">
				<c:if test="${employees == null}">
				<h4>没有任何员工信息</h4>
				</c:if>
				<c:if test="${employees != null}">
				<table class="collapse">
					<tr>
						<td>姓名</td>
						<td>性别</td>
						<td>生日</td>
						<td>部门</td>
						<td>编辑</td>
						<td>删除</td>
					</tr>
					<c:forEach items="${employees}" var="emp">
					<tr>
						<td>${emp.name}</td>
						<td>${emp.gender == 1? "男": "女"}</td>
						<td><fmt:formatDate value="${emp.birthday}" pattern="yyyy-MM-dd"/></td>
						<td>${emp.department.name}</td>
						<td><a href="${rootpath}/employee/emp/${emp.id}" >编辑</a></td>
						<td><a href="${rootpath}/employee/emp/${emp.id}" class="emp-delete">删除</a></td>
					</tr>
					</c:forEach>
				</table>
				</c:if>
				<p><a href="${rootpath}/employee/emp">添加员工</a></p>
			</div>
		</div>
	</body>
</html>
